#!/bin/bash

if [ ! -d tmp ]; then
	mkdir -p tmp
fi

if [ ! -d /etc/mavlink-router ]; then
        mkdir -p /etc/mavlink-router
fi


# install mavlink-routerd

cd tmp
tar zvxf ../mavlink-routerd.tar.gz
cp -f main.conf /etc/mavlink-router
cp -f mavlink-routerd /usr/bin


# install mavsdk

tar zvxf ../mavsdk-1.4.6.tar.gz
cp -rf mavsdk-1.4.6/usr/local/include/mavsdk /usr/local/include/
cp -rf mavsdk-1.4.6/usr/local/lib64/libmavsdk.so* /usr/local/lib64/


# install and build control

cd ../control
mkdir build && cd build && cmake .. && make
